home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung CD 2 (Tewi)(1994).iso
/
c
/
compcomp
/
os2yacc
/
ycpfir.1c
< prev
next >
Wrap
Text File
|
1989-09-29
|
2KB
|
99 lines
/*
HEADER: CUG nnn.nn;
TITLE: YACC - Yet Another Compilier-Compilier
VERSION: 1.0 for IBM-PC
DATE: JAN 28, 1985
DESCRIPTION: LALR(1) Parser Generator. From UNIX
KEYWORDS: Parser Generator Compilier-Compilier YACC
SYSTEM: IBM-PC and Compatiables
FILENAME: YCPFIR.1C
WARNINGS: This program is not for the casual user. It will
be useful primarily to expert developers.
CRC: N/A
SEE-ALSO: LEX and PREP
AUTHORS: Scott Guthery 11100 leafwood lane Austin, TX 78750
COMPILERS: DESMET-C
REFERENCES: UNIX Systems Manuals
*/
#include "y1.h"
/*
* ycpfir.1c
*
* Modified to make debug code conditionally compile.
* 28-Aug-81
* Bob Denny
*/
void cpfir( void )
{
/* compute an array with the first of nonterminals */
register *p, **s, i, **t, ch, changes;
zzcwp = &wsets[nnonter];
NTLOOP(i)
{
aryfil( wsets[i].ws.lset, tbitset, 0 );
t = pres[i+1];
for( s=pres[i]; s<t; ++s )
{
/* initially fill the sets */
for( p = *s; (ch = *p) > 0 ; ++p )
{
if( ch < NTBASE )
{
SETBIT( wsets[i].ws.lset, ch );
break;
}
else if( !pempty[ch-NTBASE] ) break;
}
}
}
/* now, reflect transitivity */
changes = 1;
while( changes )
{
changes = 0;
NTLOOP(i)
{
t = pres[i+1];
for( s=pres[i]; s<t; ++s )
{
for( p = *s; ( ch = (*p-NTBASE) ) >= 0; ++p )
{
changes |= setunion( wsets[i].ws.lset, wsets[ch].ws.lset );
if( !pempty[ch] ) break;
}
}
}
}
NTLOOP(i) pfirst[i] = flset( &wsets[i].ws );
#ifdef debug
if( (foutput!=NULL) )
{
NTLOOP(i)
{
fprintf( foutput, "\n%s: ", nontrst[i].name );
prlook( pfirst[i] );
fprintf( foutput, " %d\n", pempty[i] );
}
}
#endif
}